
package hasthi.wsdm;

import hasthi.common.BaseContext;
import hasthi.common.ComponetFactory;
import hasthi.common.HasthiException;
import hasthi.container.UnicastContianier;
import hasthi.container.XsulBasedSoapContainer;

import java.io.InputStream;
import java.util.Arrays;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;

public class ManagementAgentContext {
    private InputStream configurationStream;
   // private ManagedSystemHandle managedSystemHandle;
    private final ManagemntChangeListener changeListener;
    private final BaseContext baseContext;
    private UnicastContianier unicastContianier;
    private final ScheduledExecutorService scheduledExecutorService;
    
    public ManagementAgentContext(InputStream configurationStream,BaseContext baseContext) throws HasthiException {
        this.configurationStream = configurationStream;
        //this.managedSystemHandle = managedSystemHandle;
        changeListener = new ManagemntChangeListener();
        this.baseContext = baseContext;
        //unicastContianier = ComponetFactory.createSoapContianier(baseContext, null);
        unicastContianier = new XsulBasedSoapContainer(baseContext,null);
        scheduledExecutorService = Executors.newScheduledThreadPool(2);
    }
    
    public ManagementAgentContext(BaseContext baseContext) throws HasthiException {
        this(null,baseContext);
    }
    
    public void setUnicastContainer(UnicastContianier unicastContianier){
        this.unicastContianier = unicastContianier;
    }

    public InputStream getConfigurationStream() {
        return configurationStream;
    }
    public void setConfigurationStream(InputStream configurationStream) {
        this.configurationStream = configurationStream;
    }
//    public ManagedSystemHandle getManagedSystemHandle() {
//        return managedSystemHandle;
//    }
//    public void setManagedSystemHandle(ManagedSystemHandle managedSystemHandle) {
//        this.managedSystemHandle = managedSystemHandle;
//    }

    public ManagemntChangeListener getChangeListener() {
        return changeListener;
    }

    public BaseContext getBaseContext() {
        return baseContext;
    }

    public UnicastContianier getUnicastContianier() {
        return unicastContianier;
    }

    public ScheduledExecutorService getScheduledExecutorService() {
        return scheduledExecutorService;
    }
    
    
    public void shutDown(){
        //scheduledExecutorService.shutdown();
        scheduledExecutorService.shutdownNow();
    }
}

